Move ro /sysroot bind mount of /etc into initramfs
authorColin Walters <walters@verbum.org>
Sun, 24 May 2020 15:25:08 +0000 (15:25 +0000)
committerColin Walters <walters@verbum.org>
Sun, 24 May 2020 18:46:28 +0000 (18:46 +0000)
commit35642259175973617da937f3cab6ce5f13c95077
treec26c11583f0de06bda2206574a10ecad54038d9b
parent8801e38bba46ed586a74b733ea2e49d06ff8afd7
Move ro /sysroot bind mount of /etc into initramfs

We recently disabled the read-only /sysroot handling:
https://github.com/ostreedev/ostree/pull/2108/commits/e35b82fb891daee823fcce421ae8f1442b630ea2

The core problem was that a lot of services run early in the
real root and want write access to things like `/var` and `/etc`.

In trying to do remounts while the system is running we introduce
too many race conditions.

Instead, just make the `/etc` bind mount in the initramfs right
after we set up the main root.  This is much more natural really,
and avoids all race conditions since nothing is running in the
sysroot yet.

The main awkward part is that since we're not linking
`ostree-prepare-root` to GLib (yet) we have a hacky parser
for the config file.  But, this is going to be fine I think.

In order to avoid parsing the config twice, pass state from
`ostree-prepare-root` to `ostree-remount` via a file in `/run`.
src/switchroot/ostree-mount-util.h
src/switchroot/ostree-prepare-root.c
src/switchroot/ostree-remount.c